public class OppTest
{
    public static void test(Opportunity[] b)
    {
        //Opportunity op;
        for(Opportunity a:b)
        {
            try
            {
                a  =[select account.name from opportunity where name='Pooja'];
                a.account.name='pratibh';
                update a;
                update a.account;                
            }
            catch(Exception e)
            {
                //op.adderror('exception');
            }
                       
         }
    }
}